static GPrivate thread_current_context = G_PRIVATE_INIT (g_object_unref);
+static void
+gdk_gl_context_clear_old_updated_area (GdkGLContext *context)
+{
+ int i;
+
+ for (i = 0; i < 2; i++)
+ {
+ g_clear_pointer (&context->old_updated_area[i], cairo_region_destroy);
+ }
+}
+
static void
gdk_gl_context_dispose (GObject *gobject)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
GdkGLContext *current;
+ gdk_gl_context_clear_old_updated_area (context);
+
current = g_private_get (&thread_current_context);
if (current == context)
g_private_replace (&thread_current_context, NULL);
gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (shared), painted, damage);
return;
}
+
+ if (context->old_updated_area[1])
+ cairo_region_destroy (context->old_updated_area[1]);
+ context->old_updated_area[1] = context->old_updated_area[0];
+ context->old_updated_area[0] = cairo_region_reference (painted);
+}
+
+static void
+gdk_gl_context_surface_resized (GdkDrawContext *draw_context)
+{
+ GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
+
+ gdk_gl_context_clear_old_updated_area (context);
}
static void
draw_context_class->begin_frame = gdk_gl_context_real_begin_frame;
draw_context_class->end_frame = gdk_gl_context_real_end_frame;
+ draw_context_class->surface_resized = gdk_gl_context_surface_resized;
/**
* GdkGLContext:shared-context:
struct _GdkGLContext
{
GdkDrawContext parent_instance;
+
+ /* We store the old drawn areas to support buffer-age optimizations */
+ cairo_region_t *old_updated_area[2];
};
struct _GdkGLContextClass
started. It may be smaller than the expose area if we'e painting
more than we have to, but it represents the "true" damage. */
cairo_region_t *active_update_area;
- /* We store the old expose areas to support buffer-age optimizations */
- cairo_region_t *old_updated_area[2];
GdkSurfaceState old_state;
GdkSurfaceState state;
recalculate_children);
}
-static void
-gdk_surface_clear_old_updated_area (GdkSurface *surface)
-{
- int i;
-
- for (i = 0; i < 2; i++)
- {
- if (surface->old_updated_area[i])
- {
- cairo_region_destroy (surface->old_updated_area[i]);
- surface->old_updated_area[i] = NULL;
- }
- }
-}
-
-static void
-gdk_surface_append_old_updated_area (GdkSurface *surface,
- cairo_region_t *region)
-{
- if (surface->old_updated_area[1])
- cairo_region_destroy (surface->old_updated_area[1]);
- surface->old_updated_area[1] = surface->old_updated_area[0];
- surface->old_updated_area[0] = cairo_region_reference (region);
-}
-
void
_gdk_surface_update_size (GdkSurface *surface)
{
for (l = surface->draw_contexts; l; l = l->next)
gdk_draw_context_surface_resized (l->data);
- gdk_surface_clear_old_updated_area (surface);
recompute_visible_regions (surface, FALSE);
}
gdk_surface_process_updates_recurse (surface, expose_region);
- gdk_surface_append_old_updated_area (surface, surface->active_update_area);
-
cairo_region_destroy (expose_region);
}
impl_class->hide (surface);
}
- gdk_surface_clear_old_updated_area (surface);
recompute_visible_regions (surface, FALSE);
if (was_mapped && !gdk_surface_has_impl (surface))
gdk_gl_context_clear_current ();
recompute_visible_regions (surface, FALSE);
- gdk_surface_clear_old_updated_area (surface);
}
}
if (buffer_age == 2)
{
- if (surface->old_updated_area[0])
- return cairo_region_copy (surface->old_updated_area[0]);
+ if (context->old_updated_area[0])
+ return cairo_region_copy (context->old_updated_area[0]);
}
else if (buffer_age == 3)
{
- if (surface->old_updated_area[0] &&
- surface->old_updated_area[1])
+ if (context->old_updated_area[0] &&
+ context->old_updated_area[1])
{
- cairo_region_t *damage = cairo_region_copy (surface->old_updated_area[0]);
- cairo_region_union (damage, surface->old_updated_area[1]);
+ cairo_region_t *damage = cairo_region_copy (context->old_updated_area[0]);
+ cairo_region_union (damage, context->old_updated_area[1]);
return damage;
}
}
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
Display *dpy = gdk_x11_display_get_xdisplay (display);
- GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
unsigned int buffer_age = 0;
if (display_x11->has_glx_buffer_age)
if (buffer_age == 2)
{
- if (surface->old_updated_area[0])
- return cairo_region_copy (surface->old_updated_area[0]);
+ if (context->old_updated_area[0])
+ return cairo_region_copy (context->old_updated_area[0]);
}
else if (buffer_age == 3)
{
- if (surface->old_updated_area[0] &&
- surface->old_updated_area[1])
+ if (context->old_updated_area[0] &&
+ context->old_updated_area[1])
{
- cairo_region_t *damage = cairo_region_copy (surface->old_updated_area[0]);
- cairo_region_union (damage, surface->old_updated_area[1]);
+ cairo_region_t *damage = cairo_region_copy (context->old_updated_area[0]);
+ cairo_region_union (damage, context->old_updated_area[1]);
return damage;
}
}